# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Timothy Redaelli <timothy.redaelli@gmail.com>
# Contributor: Frank Ickstadt (frank dot ickstadt at gmail dot com)

pkgname=argyllcms
pkgver=2.3.1
pkgrel=3
pkgdesc="An ICC compatible color management system with support for different colorimeter hardware"
arch=(loong64 x86_64)
url="https://www.argyllcms.com/"
license=(GPL AGPL)
depends=(libpng libtiff libxss libxinerama libxxf86vm libxrandr zlib openssl)
makedepends=(ftjam zip unzip)
source=("https://www.argyllcms.com/Argyll_V${pkgver}_src.zip")
sha256sums=('bd0bcf58cec284824b79ff55baa242903ed361e12b1b37e12228679f9754961c')

prepare() {
    cd Argyll_V${pkgver}
    # Use hwdb builtin, instead of the obsolete usb-db in the udev rules.
    sed -i 's:^TEST=="/lib/udev/usb-db", IMPORT{program}="usb-db %p":IMPORT{builtin}="hwdb --subsystem=usb":' usb/55-Argyll.rules

    # Use LDFLAGS
    echo "LINKFLAGS += ${LDFLAGS} ;" >> Jamtop
}

build() {
    cd Argyll_V${pkgver}
    CCOPTFLAG="$CFLAGS"
    jam -q -fJambase ${MAKEFLAGS} -sPREFIX=/usr -sDESTDIR="${pkgdir}" -sREFSUBDIR=share/argyllcms/ref all
}

package() {
    cd Argyll_V${pkgver}
    jam -q -fJambase ${MAKEFLAGS} -sPREFIX=/usr -sDESTDIR="${pkgdir}" -sREFSUBDIR=share/argyllcms/ref install

    rm "${pkgdir}"/usr/bin/License.txt

    rm {doc,ref}/afiles
    install -Dm644 doc/*.* -t "${pkgdir}"/usr/share/${pkgname}/doc/
    install -Dm644 doc/ccmxs/*.ccmx -t "${pkgdir}"/usr/share/${pkgname}/doc/ccmxs/

    install -Dm644 usb/55-Argyll.rules -t "${pkgdir}"/usr/lib/udev/rules.d/
}
